package dominion.model;

import java.io.IOException;
import java.util.List;

public abstract class Card {

	protected int cost;
	protected int value;

	public int getCost() {
		return cost;
	}
	
	public int getValue(){
		return value;
	}
	
	public void setValue(int value){
		this.value = value;
	}

	public boolean equals(Object obj) {
		boolean equals;
		if (obj == null || !(obj instanceof Card))
		{
			equals = false;
		}
		else
		{
			Card card = (Card) obj;
			if (this.toString().equals(card.toString()))
			{
				equals = true;
			}
			else
			{
				equals = false;
			}
		}
		return equals;
	}

	public abstract Card clone();

	public abstract String toString();

	public String getDescription() {
		StringBuffer sb = new StringBuffer();
		sb.append("Title: " + toString() + "\n");
		sb.append("Cost: " + cost + "\n");
		return sb.toString();
	}

	public abstract void doAction(Player player, GameBoard board, List<Player> players) throws IOException;

	public int compareTo(Card card) {
		int result = this.cost - card.getCost();
		if (result == 0)
		{
			result = this.toString().compareTo(card.toString());
		}
		return result;
	}
}
